package page2;

import java.util.Scanner;

public class Ques1842 {
	
	public void swap(int arr[],int i,int j){
//		if(arr[i] == arr[j]){
//			return;
//		}
		int temp = arr[i];
		arr[i] = arr[j];
		arr[j] = temp;
	}
	
	
	
	public void go(){
		Scanner scan = new Scanner(System.in);
		int[] arr = new int[]{1,2,3,4,5,6,7,8,9};
		int n,m,p,sum;
		int[] b = new int[1000100];
		while(scan.hasNext()){
			int N = scan.nextInt();
			for(int i = 0;i < 7;i++){
				for(int j = i+1;j <= 7;j++){
					n = 0;
					m = 0;
					p = 0;
					for(int k = 0;k <= i;k++){
						n = n*10+arr[k];
					}
					System.out.println("n->"+n);
					for(int k = i+1;k <= j;k++){
						m = m*10+arr[k];
					}
					System.out.println("m->"+m);
					for(int k = j+1;k <= 8;k++){
						p = p*10+arr[k];
					}
					System.out.println("p->"+p);
					if(m % p == 0){
						sum = n+m/p;
						if(sum < 1000000){
							b[sum]++;
						}
					}
				}
			}
			System.out.println(b[N]);
		}
	}
	
	public static void main(String[] args) {
		new Ques1842().go();
	}
}
